package springweb.form.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import springweb.form.SimplePersonForm;

public class SimplePersonFormValidator implements Validator {

	public boolean supports(Class clazz) {
		return clazz.equals(SimplePersonForm.class);
	}

	public void validate(Object command, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", null, "First name is required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", null, "Last name is required");
	}

}
